home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9700 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  50 lines

  1. Path: navet.enator.se!usenet
  2. From: Robin Rosenberg <rrg@funsys.se>
  3. Newsgroups: comp.os.ms-windows.programmer.tools,com.os.ms-windows.programmer.tools.misc,comp.os.ms-windows.win95.misc,comp.lang.c++,
  4. Subject: Re: Reboot for Windows
  5. Date: Mon, 04 Mar 1996 00:58:48 -0800
  6. Organization: Enator Objective Management AB
  7. Message-ID: <313AB0C8.21D5@funsys.se>
  8. References: <4h46en$r9b@mn5.swip.net> <3136C5A3.3564@ftp.com>
  9. NNTP-Posting-Host: 194.18.172.178
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14.  
  15. Joseph M. Koral wrote:
  16. > Walter Lam wrote:
  17. > > Does anyone know where I can get the source code, or executable for a PC
  18. > > reboot program under Windows?  I've got one for dos, but it doesn't work
  19. > > under windows/windows 95......
  20. > One possibilty might be to figure out how to call the Win95 reboot VxD yourself.  Check out
  21. > Matt Pietrek's Win95 System Secrets book for more details.
  22. > - Joseph
  23.  
  24. It's very simple since windows has an API call for just this purpose. I create a file
  25. to tell autoexec that I didn't crash.
  26.  
  27. #include <Windows.h>
  28.  
  29. int
  30. PASCAL
  31. WinMain(HINSTANCE, HINSTANCE, LPSTR, int nCmdShow)
  32. {
  33.      if (MessageBox(NULL/*owner window*/,
  34.     "Vill du verkligen starta om systemet?",
  35.     "Winboot",
  36.     MB_ICONSTOP | MB_YESNO)==IDYES) {
  37.         OFSTRUCT ofs = { sizeof(OFSTRUCT), TRUE, 0, {0,0,0,0}, "C:\\REBOOT.DAT"};
  38.         HFILE f=_lcreat("C:\\REBOOT.DAT", 0);
  39.         if (f) _lclose(f);
  40.         ExitWindows(EW_REBOOTSYSTEM,0);
  41.     }
  42.     }
  43. }
  44.  
  45. -- robin
  46.